package com.zju.searchEngine.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zju.searchEngine.mapper.WebPageMapper;
import com.zju.searchEngine.model.WebPage;
import com.zju.searchEngine.model.WebPageExample;
import com.zju.searchEngine.model.WebPageWithBLOBs;
import com.zju.searchEngine.service.IWebPageService;

@Service
public class WebPageService implements IWebPageService {
	
	@Autowired
	private WebPageMapper webPageMapper;

	@Override
	public WebPage selectById(Integer id) {
		return webPageMapper.selectByPrimaryKey(id);
	}

	@Override
	public int insert(WebPageWithBLOBs webPageWithBLOBs) {
		return webPageMapper.insert(webPageWithBLOBs);
	}

	@Override
	public List<String> selectAllTags() {
		WebPageExample webPageExample = new WebPageExample();
		List<WebPage> webPageList = webPageMapper.selectByExample(webPageExample);
		List<String> list = new ArrayList<String>();
		for (WebPage webPage : webPageList) {
			list.add(webPage.getTags());
		}
		return list;
	}

}
